    //关闭搜索
    function closeSearch(){
        $('#page-wrapper .navbar-header .btn-search').html('<i class="fa fa-search"></i>');
        $(".searchNav").attr('class','searchNav searchHide');
        $("#page-wrapper").css('margin-right','0px');
    }
    //打开搜索
    function openSearch(){
        $('#page-wrapper .navbar-header .btn-search').html('<i class="fa fa-close"></i>');
        $(".searchNav").attr('class','searchNav searchShow');
        $("#page-wrapper").css('margin-right','350px');
    }

$(function(){
    // $("#searchNavId").on('mousemove',function(ev){
    //     var e = ev||Event;
    //     var searchLeft = $(this).offset();
    //     var cx= e.offsetX;
    //     var fx= e.offsetX-searchLeft.left;

    //     if(cx<2){
    //         $("#searchNavId").css('cursor','e-resize');
    //     }else{
    //         $("#searchNavId").css('cursor','auto');
    //     }

    //     $("#searchNavId").on("mousedown",function(ev){
            
    //     });
    //     console.log({cx:cx,fx:fx});
    // });

    

})

window.onload=function(){
 
    drag(document.getElementById("searchNavId"));

    function drag(obj) {
        var J_iframe = document.getElementById('J_iframe');
        obj.onmousedown = function (e) {
            e = e || event;
            var dir = ""; //设置好方向
            var firstX = e.clientX; //获取第一次点击的横坐标
            var firstY = e.clientY; //获取第一次点击的纵坐标
            var width = obj.offsetWidth; //获取到元素的宽度
            var height = obj.offsetHeight; //获取到元素的高度
            var Left = obj.offsetLeft; //获取到距离左边的距离
            var Top = obj.offsetTop; //获取到距离上边的距离
            //下一步判断方向距离左边的距离+元素的宽度减去自己设定的宽度，只要点击的时候大于在这个区间，他就算右边
            if (firstX > Left + width - 30) {
                dir = "right";
            } else if (firstX < Left + 30) {
                dir = "left";
            }
            if (firstY > Top + height - 30) {
                dir = "down";
            } else if (firstY < Top + 30) {
                dir = "top";
            }
            //判断方向结束
            document.onmousemove = function (e) {
                e = e || event;
                switch (dir) {
                    case "left":
                        var setWidth = width - (e.clientX - firstX);

                        if (setWidth <= 350) setWidth = 350;
                        //    obj.style["left"] = Left+(e.clientX-firstX)+"px";
                        obj.style["width"] = setWidth + "px";
                        $("#page-wrapper").css('margin-right', setWidth + "px");
                        break;
                }
            }

            J_iframe.onmousemove = function(){console.log('move')};
            

            obj.onmouseup = function () {
                document.onmousemove = null;
            }
            
            return false;
        }
    }
}
